package com.moyun.zbmy.zizhou.ui.adapter.holder;

import android.content.Context;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.moyun.zbmy.zizhou.R;
import com.moyun.zbmy.zizhou.beans.FCityItem;
import com.moyun.zbmy.zizhou.beans.GovItemBean;

import butterknife.BindView;
import butterknife.ButterKnife;

public class GovServiceHolder extends BaseAbsHolder<FCityItem> {
    @BindView(R.id.item_gov_1)
    TextView itemGov1;
    @BindView(R.id.ll_gov_1)
    LinearLayout llGov1;
    @BindView(R.id.item_gov_2)
    TextView itemGov2;
    @BindView(R.id.ll_gov_2)
    LinearLayout llGov2;
    private FCityItem item;
    public GovServiceHolder(Context context, View itemView,OnGovServiceClick serviceClick) {
        super(context, itemView);
        this.serviceClick=serviceClick;
        ButterKnife.bind(this, itemView);
    }

    @Override
    public void setData(FCityItem fCityState) {
        this.item=fCityState;
        if(fCityState.getInstitutionList().size()==1){
            llGov2.setVisibility(View.INVISIBLE);
            itemGov1.setText(fCityState.getInstitutionList().get(0).getInstitutionName());
        }else {
            llGov2.setVisibility(View.VISIBLE);
            itemGov1.setText(fCityState.getInstitutionList().get(0).getInstitutionName());
            itemGov2.setText(fCityState.getInstitutionList().get(1).getInstitutionName());
        }
        llGov1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(serviceClick!=null){
                    serviceClick.OnGovServiceClick(item.getInstitutionList().get(0));
                }
            }
        });
        llGov2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(serviceClick!=null){
                    serviceClick.OnGovServiceClick(item.getInstitutionList().get(1));
                }
            }
        });

    }
    private OnGovServiceClick serviceClick;

    public OnGovServiceClick getServiceClick() {
        return serviceClick;
    }

    public void setServiceClick(OnGovServiceClick serviceClick) {
        this.serviceClick = serviceClick;
    }

    public interface OnGovServiceClick{
        void OnGovServiceClick(GovItemBean item);
    }
}
